﻿using System;
using System.Runtime.Serialization;

namespace Invoicing.Model.Members
{
    [DataContract]
    public class CustomerModel : MBase
    {
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        [DataMember]
        public int ID { get; set; }
        [Model]
        [DataMember]
        public string Corporation { get; set; }
        [Model]
        [DataMember]
        public string RealName { get; set; }
        [Model]
        [DataMember]
        public string Address { get; set; }
        [Model]
        [DataMember]
        public string Mobile { get; set; }
        [Model]
        [DataMember]
        public int CType { get; set; }
        [Model]
        [DataMember]
        public string Pinyin { get; set; }
        [Model]
        [DataMember]
        public int SortIndex { get; set; }
        [Model]
        [DataMember]
        public int Status { get; set; }
        [Model]
        [DataMember]
        public string BankAccount { get; set; }
        [Model]
        [DataMember]
        public string Telephone { get; set; }
        [Model]
        [DataMember]
        public string DeliverInfo { get; set; }

        #region Help
        [DataMember]
        public CustomerCategoryCollection Categories { get; set; }
        [DataMember]
        public string ComplexName
        {
            get
            {
                var ret = RealName;
                if (!string.IsNullOrEmpty(Corporation))
                    ret += string.Format("【{0}】", Corporation);
                return ret;
            }
        }
        [DataMember]
        public string SearchLabel
        {
            get
            {
                return string.Format("{0} {1} {2}", Pinyin, RealName, Mobile);
            }
        }

        [DataMember]
        public decimal Balance { get; set; }
        [DataMember]
        public decimal Due { get; set; }
        [DataMember]
        public decimal Paid { get; set; }
        [DataMember]
        public decimal UnPaid { get { return Due - Paid; } }
        #endregion
    }
    [DataContract]
    public class CustomerCollection : ModelCollectionBase<CustomerModel> { }
}
